import axiosRequest from "@/api/axios-optimize"

// 判断是否存在
export function judgeUserNameExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/judgeUserNameExist`, data, config)
}

// 判断是否存在
export function judgePhoneNumberExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/judgePhoneNumberExist`, data, config)
}

// 判断是否存在
export function judgeEmailExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/judgeEmailExist`, data, config)
}

// 获取列表
export function getList(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/user`, { params: data, ...config})
}

// 获取详情
export function getDetailById(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/user/${data.id}`, { params: {}, ...config})
}

// 更新
export function updateItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.put(`/xiaobuAdmin/system/user/${data.userId}`, data, config)
}

// 新增
export function createItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user`, data, config)
}

// 删除
export function deleteItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.delete(`/xiaobuAdmin/system/user/${data.id}`, {}, config)
}

// 批量删除
export function batchDeleteItems(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/batchDelete`, data, config)
}

// 改变状态
export function changeStatus(data = {}, config = {
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/changeStatus`, data, config)
}

// 重置密码
export function resetPassword(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/resetPassword`, data, config)
}

// 通过用户ID导出对应数据
export function exportUserByUserIds(data = {}, config = {
  preventDuplicateRequestsType: "prevent",
  responseType: "arraybuffer"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/exportUserByUserIds`, data, config)
}

// 通过搜索条件导出全部数据
export function exportUserByQuery(data = {}, config = {
  preventDuplicateRequestsType: "prevent",
  responseType: "arraybuffer"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/exportUserByQuery`, data, config)
}

// 校验文件
export function validateImportFile(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/user/validateImportFile`, data, config)
}

// 确定导入文件
export function confirmImport(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`xiaobuAdmin/system/user/confirmImport`, data, config)
}
